<template>
  <div id="#app">
    <BasicLayout />
  </div>
</template>

<style>
#app {
}
</style>
<script setup lang="ts">
import BasicLayout from "@/layouts/BasicLayout";
import { useRouter } from "vue-router";
import { useStore } from "vuex";
import ACCESS_ENUM from "@/access/accessEnum";
import { onMounted } from "vue";

const router = useRouter();
const store = useStore();

// TODO:全局项目入口，用来调用全局项目函数方法，全局单次调用的代码

const doInit = () => {
  console.log("欢迎来到海氦OJ判题系统");
};

onMounted(() => {
  doInit();
});

router.beforeEach((to, from, next) => {
  // 判断是否为管理员界面
  if (to.meta?.access === ACCESS_ENUM.ADMIN) {
    // 判断此用户是否为管理员
    if (store.state.loginUser?.userRole !== "admin") {
      next("/no");
      return;
    }
  }
  next();
  console.log(to);
});
</script>